package com.jackson.rocketmqdemo.service.Producer;

/*
 * Author: JacksonCoder
 * FileName: MessageProducer
 * Version: 1.0.0
 * Date: 2025/4/28
 */

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;

@Service
public class MessageProducer {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    public void sendMessage(String topic, String message){
        rocketMQTemplate.send(topic, MessageBuilder.withPayload(message).build());
    }

}
